import React, {Component} from 'react';


function ShowNumber(props = {}) {
  props.num = 5;
  return <h1>{props.num}</h1>
}


// 类组件传递参数
class Child2 extends Component {
  render() {
    return (
      <div>
        <h1>接受到的数字是{this.props.num}</h1>
      </div>
    );
  }

}


// 函数组件的传值
class Index extends Component {
  render() {
    return (
      <div>
        <ShowNumber num={1}/>
        <hr/>
        <ShowNumber num={4}/>
        <hr/>
        <Child2 num={5}/>
      </div>
    );
  }
}

export default Index;
